<template>
  <a-modal v-model="isModal" :title="title" @ok="confirm()" forceRender destroyOnClose>
    <slot name="head" />
    <a-textarea v-model="remark" :placeholder="placeholder" :max-length="max" :autoSize="{ minRows: 4, maxRows: 4 }" />
    <slot name="foot" />
  </a-modal>
</template>
<script>
export default {
  props: {
    // 最大输入长度
    max: {
      typeof: Number,
      default: 1500,
    },
  },
  data() {
    return {
      otherParams: undefined, // 其它方法调用需要的参数
      remark: undefined,
      placeholder: undefined, // 空状态提示
      title: undefined, // 模态框标题
      funName: undefined, // 方法名称
      isModal: false,
    }
  },
  created() {},
  methods: {
    // 模态框确认
    confirm() {
      if(!this.remark) {
        this.$message.warning(this.placeholder)
        return
      }
      this.$emit('f_confirm', this.funName, this.remark, this.otherParams)
    },
    // 父组件调用关闭
    f_close() {
      this.isModal = false
    },
    //  父组件调用初始化
    f_init(title, funName, placeholder, otherParams = {}) {
      this.remark = undefined
      this.otherParams = otherParams
      this.placeholder = placeholder
      this.title = title
      this.funName = funName
      this.isModal = true
    },
  },
}
</script>

<style lang="scss" scoped>
</style>
